import axios from 'axios';
import { vueAxios } from './plugins';
import {
  setupRequestInterceptor,
  setupResponseInterceptor,
  setupRepeatSubmitInterceptor,
  setupConcurrentRequestInterceptor,
} from './interceptors';

const config = {
  baseURL: import.meta.env.VITE_APP_APIURL,
  timeout: 10000,
  headers: {
    'content-type': 'application/json',
  },
};

const http = axios.create(config);
setupRepeatSubmitInterceptor(http);
setupConcurrentRequestInterceptor(http);

setupRequestInterceptor(http);
setupResponseInterceptor(http);

export const setupHttp = (app) => {
  app.use(vueAxios, http);
};

export default http;
